<?php
/*=============================================================================
|| ##################################################################
||	phpFoX Konsort
|| ##################################################################
||	
||	Copyright		: (C) 2005-2007 PHPFOX Limited a Reality Fox Creation
||	Contact			: info@phpfox.com
||
||	- phpFoX and all of its source code and files are protected by Copyright Laws. 
||
||	- The license for phpFoX permits you to install this software on a single domain (.com, .org, .net, etc.). 
||
||	- You may also not remove this copyright screen which shows the copyright information and credits for phpFoX (RealityFOX Creations). 
||
||	- phpFoX Konsort is NOT a FREE software - http://www.phpfox.com/license/
||
|| ##################################################################
=============================================================================*/

/* $File: ./include/modules/Account/classes/PhpFox_ComponentAvatar.class.php, $Author:  $ */


require_once PHPFOX_INCLUDE . 'classes/smarty/plugins/function.img.php';

/** User settings
 * 
 * Parameters:
 *  1. oUser (required) - user account object
 * 
 * @package module.account
 * @version $Id: PhpFox_ComponentAvatar.class.php 46 2007-12-14 23:12:21Z phpfoxsv $
 *   
 */
class PhpFox_Mod_Account_ComponentAvatar extends BaseComponent
{

    /** Processing method
     */
	function process()
	{
	    $sImageUrl = App::getParam('user.pic.url');
	    $iSize = $this->getParam('iSize', 75);
	    $sUser = $this->getParam('sUser');
	    
	    /* Gender based Avatar Mod */		
	    $oSrvAcc = &App::getModuleService('Account', 'Account');
		
	    $oUser = $oSrvAcc->getByUsername($sUser);
	    $aGenders = App::getOptions('gender');
	    if(isset($aGenders[$oUser->aData['gender']])){
	    	if(  strtolower($aGenders[$oUser->aData['gender']])=='male'){
		    	$gender = "male";
		    }else{
		    	$gender = "female";	    
		    }
		    $this->_aParams['src_def2']   = App::getParam('url').'design/pic/gender/'.$gender.'_'.$iSize.'.jpg';
	    
	    
	    }else{
		$this->_aParams['src_def2']   = App::getParam('url').'design/pic/noimage_'.$iSize.'.jpg';
	    }

	    $this->_aParams['src']        = $sImageUrl.$sUser.'_'.$iSize.'.jpg' . (App::getParam('force_re_cache') ? '?id=' . md5(rand(1003, 203948394)) : '');
	    $this->_aParams['src_def']    = $sImageUrl.$sUser.'.jpg';
	    //$this->_aParams['src_def2']   = App::getParam('url').'design/pic/noimage_'.$iSize.'.jpg';
	    $this->_aParams['max_width']  = $iSize;
	    $this->_aParams['max_height'] = $iSize;
	    if (!isset($this->_aParams['alt'])) {
	        $this->_aParams['alt'] = "";
	    }
	    unset($this->_aParams['sUser']);
        unset($this->_aParams['iSize']);

        $oTpl = &$this->_oModule->getTemplate();
	    $srcHtml = smarty_function_img($this->_aParams, $oTpl);
		return $srcHtml;
	}

}
?>